<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="newtemplatesfiles5/img/favicon.html">

    <title>设置个人信息</title>

    <!-- Bootstrap core CSS -->
    <link href="newtemplatesfiles5/css/bootstrap.min.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="newtemplatesfiles5/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="newtemplatesfiles5/css/style.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="newtemplatesfiles5/js/html5shiv.js"></script>
      <script src="newtemplatesfiles5/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">

      <!--header start-->
      <div th:insert="common/student-common-header::top"></div>
      <!--header end-->
      <!--sidebar start-->
      <div th:insert="common/student-common-sidebar::#left"></div>
      <!--sidebar end-->
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!-- page start-->
              <div class="row">
                  <!--student-info-left  start-->
                  <div th:insert="common/student-info-left::#student-info-left"></div>
                  <!--student-info-left  end-->

                  <aside class="profile-info col-lg-9">
                      <section class="panel">
                          <div class="bio-graph-heading">
                              <h2>修改个人信息</h2>
                          </div>
                          <div class="panel-body bio-graph-info">
                              <form class="form-horizontal" role="form" id="studentInfoForm">
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">学号</label>
                                      <div class="col-lg-6">
                                          <input name="stdentID" disabled type="text" class="form-control" placeholder="" th:value="${session.studentInfo.studentID}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">姓名</label>
                                      <div class="col-lg-6">
                                          <input name="name" disabled type="text" class="form-control" placeholder="" th:value="${session.studentInfo.name}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">学校</label>
                                      <div class="col-lg-6">
                                          <input name="universityName" disabled type="text"  class="form-control" placeholder="" th:value="${session.studentInfo.universityName}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">学院</label>
                                      <div class="col-lg-6">
                                          <input name="department" disabled type="text" class="form-control" placeholder="" th:value="${session.studentInfo.departmentName}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">班级</label>
                                      <div class="col-lg-6">
                                          <input name="className" type="text" disabled class="form-control" placeholder="" th:value="${session.studentInfo.className}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">昵称</label>
                                      <div class="col-lg-6">
                                          <input name="nickName" type="text" class="form-control" placeholder="" th:value="${session.studentInfo.nickName}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">邮箱</label>
                                      <div class="col-lg-6">
                                          <input name="email" type="text" class="form-control" placeholder="zhangsan@atguigu.com" th:value="${session.studentInfo.emial}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">手机</label>
                                      <div class="col-lg-6">
                                          <input name="phoneNumber" type="text" class="form-control" placeholder="" th:value="${session.studentInfo.phoneNumber}">
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label  class="col-lg-2 control-label">头像</label>
                                      <div class="col-lg-6">
                                          <img style="width: 60px" id="show" th:src="${session.studentInfo.image}" alt=""><br>
                                          <input type="file" class="file-pos" id="myfile" name="image" onchange="showImage()">
                                      </div>
                                  </div>

                              </form>
                              <div class="form-group">
                                  <div class="col-lg-offset-2 col-lg-10">
                                      <button type="submit" class="btn btn-success" onclick="studentInfoSubmit()">保存</button>
                                  </div>
                              </div>
                          </div>

                      </section>
                      <script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
                      <script type="text/javascript" src="js/jquery.min.js"></script>
                      <script src="asserts/js/popper.min.js"></script>
                      <script src="asserts/js/feather.min.js"></script>
                      <script src="asserts/js/bootstrap.min.js"></script>
                      <script type="text/javascript">
                          //图片回显
                          function showImage() {
                              var reader = new FileReader();
                              var file = document.getElementById("myfile").files[0];
                              console.log(file);
                              reader.onload=function (e) {
                                  ///console.log(this.result);
                                  document.getElementById('show').src=this.result;
                              };
                              reader.readAsDataURL(file);
                          }


                          function verifyLoginStatus() {
                              //验证登录状态
                              console.log("1");
                              var message = document.getElementById("mystatus").innerText;
                              console.log(message);
                              if(message == '请先登录'){
                                  alert("请登录");
                                  location.href="login";
                                  return '1';
                              }
                              return '2';
                          }

                          //表单提交
                          function studentInfoSubmit() {

                              var status = verifyLoginStatus();

                              if(status == '2'){
                                  var form = new FormData(document.getElementById("studentInfoForm"));

                                  $.ajax({
                                      url:"finishStudentInfo.do",
                                      type:"post",
                                      dataType:"html",
                                      data:form,
                                      cache:false,
                                      processData:false,
                                      contentType:false,
                                      success: function (data) {
                                          if(data=="success"){
                                              alert("修改成功！");
                                              location.href="getStudentInfo.do";
                                          }else{
                                              alert(data);
                                          }
                                      },
                                      error:function (data) {
                                          console.log("error");
                                          alert(data);
                                      }
                                  })
                              }

                          }
                      </script>
                  </aside>
              </div>

              <!-- page end-->
          </section>
      </section>
      <!--main content end-->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="newtemplatesfiles5/js/jquery.js"></script>
    <script src="newtemplatesfiles5/js/bootstrap.min.js"></script>
    <script src="newtemplatesfiles5/js/jquery.scrollTo.min.js"></script>
    <script src="newtemplatesfiles5/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="newtemplatesfiles5/assets/jquery-knob/js/jquery.knob.js"></script>

    <!--common script for all pages-->
    <script src="newtemplatesfiles5/js/common-scripts.js"></script>


  </body>
</html>
